package org.obsidianrad.server.services.user.rolemanager;


import java.util.Map;

import org.obsidianrad.server.services.obj2db.dao.GenericProxy;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.security.GrantedAuthority;

public abstract class RoleManager implements ApplicationContextAware{
	private ApplicationContext context;
	
	@SuppressWarnings("unchecked")
	private Map<String, GenericProxy> genericProxies = null;
	
	public abstract GrantedAuthority[] getGrantedAuthorities();

	public abstract String constructRole(String reference, Object ... params);
	

	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		this.context = applicationContext;
	}

	
	@SuppressWarnings("unchecked")
	public Map<String, GenericProxy> getProxies(){
		if(genericProxies == null){
			genericProxies = context.getBeansOfType(GenericProxy.class);
		}
		return genericProxies;
	}

	public abstract Map<String, Map<String, String>> getDataForAuth();
	
}
